{extend name="layout:base" /}

{block name="content"}
<div class="layui-fluid">

    <div class="layui-card">
        <div class="layui-card-header">{$article.name} -  客服： {$article.kfName}


<!-- <a target="_blank" title="点击打开qq" href="http://wpa.qq.com/msgrd?v=3&uin=12345678&site=qq&menu=yes">{$article.kfEmail}</a>-->
</div>
        <div class="layui-card-body">
            <table class="layui-table" lay-filter="test1">
                <thead>
                <tr>
                    <th lay-data="{field:'userName',width:80}">签单人</th>
                    <th lay-data="{field:'money',width:100}">签单金额</th>
                    <th lay-data="{field:'signTime',width:110}">签单时间</th>
                    <th lay-data="{field:'typeName',width:100}">签单类型</th>
                    <th lay-data="{field:'url',width:150}">客户域名</th>
                    <th lay-data="{field:'isSeo'}">优化</th>
                    <th lay-data="{field:'isBeiAn'}">备案</th>
                    <th lay-data="{field:'beiAnText',minWidth:150}">备案资料</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{$article.userName}</td>
                    <td>{$article.money}</td>
                    <td>{$article.signTime}</td>
                    <td>{$article.typeName}</td>
                    <td>{$article.url}</td>
                    <td>{if condition="$article.isSeo==1"}是{/if} {if condition="$article.isSeo==0"}否{/if}</td>
                    <td>{if condition="$article.isBeiAn==1"}是{/if} {if condition="$article.isBeiAn==0"}否{/if}</td>
                    <td>{$article.beiAnText}</td>
                </tr>
            </table>
            <table class="layui-table" lay-filter="test2">
                <thead>
                <tr>
                    <th lay-data="{field:'kfName',style:'background-color: #009688; color: #fff;'}">客服</th>
<!--                    <th lay-data="{field:'dataGetTime',style:'background-color: #009688; color: #fff;'}">资料收集时间</th>-->
                    <th lay-data="{field:'special',style:'background-color: #009688; color: #fff;'}">特殊要求</th>
                    <th lay-data="{field:'content'}">备注</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{$article.kfName}</td>
<!--                    <td>{$article.dataGetTime}</td>-->
                    <td>{$article.special}</td>
                    <td>{$article.content}</td>
                </tr>
            </table>
            <table class="layui-table" lay-filter="test3">
                <thead>
                <tr>
                    <th lay-data="{field:'editName'}">编辑</th>
                    <th lay-data="{field:'editTime'}">分配时间</th>
                    <th lay-data="{field:'templateTime'}">模版确认</th>
                    <th lay-data="{field:'templateUrl'}">模版地址</th>

                    <th lay-data="{field:'techName'}">技术</th>
                    <th lay-data="{field:'techTime'}">分配时间</th>
                    <th lay-data="{field:'techEndTime'}">框架完成时间</th>
                    <th lay-data="{field:'techTxt'}">框架备注</th>
                    <th lay-data="{field:'dataEndTime'}">资料传完时间</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{$article.editName}</td>
                    <td>{$article.editTime}</td>
                    <td>{$article.templateTime}</td>
                    <td>{$article.templateUrl}</td>
                    <td>{$article.techName}</td>
                    <td>{$article.techTime}</td>
                    <td>{$article.techEndTime}</td>
                    <td>{$article.techTxt}</td>
                    <td>{$article.dataEndTime}</td>
                </tr>
            </table>

<!--分配技术,-->

            {if condition="$article.state==0"}
                <!--框架完成时间和备注-->
                {if condition="($Think.session.admin.id==$article.techID and $article.techEndTime==null) or $Think.session.admin.levelNum==50"}
                <form class="layui-form">
                    <input type="hidden" name="id" value="{$article.id}">
                    <input type="hidden" name="websiteName" value="{$article.name}">
                    <input type="hidden" name="editID" value="{$article.editID}">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>框架完成时间</th>
                            <th>框架备注</th>
                            <th></th>
                        </tr>
                        </thead>
                        <tr>
                            <td>
                                <div class="layui-inline">
                                    <input type="text" name="techEndTime" id="techEndTime" value="" autocomplete="off" class="layui-input" lay-verify="required">
                                </div>
                            </td>
                            <td>
                                <textarea name="techTxt" lay-verify="required" placeholder="框架后台，帐号密码等" style="width: 100%">{$article.techTxt}</textarea>
                            </td>
                            <td>
                                <button class="layui-btn" lay-submit="" lay-filter="btn_setTechEndTime">保存</button>
                            </td>
                        </tr>
                    </table>
                </form>
                {/if}

                {if condition="($Think.session.admin.id==$article.editID and $article.templateTime==null) or $Think.session.admin.levelNum==50"}
                <form class="layui-form">
                    <input type="hidden" name="id" value="{$article.id}">
                    <input type="hidden" name="websiteName" value="{$article.name}">
                    <input type="hidden" name="techID" value="{$article.techID}">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>模版确认时间</th>
                            <th>模版地址</th>
                            <th></th>
                        </tr>
                        </thead>
                        <tr>
                            <td>
                                <div class="layui-inline">
                                    <input type="text" name="templateTime" id="templateTime" value="" autocomplete="off" class="layui-input" lay-verify="required">
                                </div>
                            </td>
                            <td>
                                <input type="text" name="templateUrl" value="" autocomplete="off" class="layui-input" lay-verify="required">
                            </td>
                            <td>
                                <button class="layui-btn" lay-submit="" lay-filter="btn_setTemplate">保存</button>
                            </td>
                        </tr>
                    </table>
                </form>
                {/if}

    <!--资料完成时间-->
                {if condition="($Think.session.admin.id==$article.editID and $article.dataEndTime==null) or $Think.session.admin.levelNum==50"}
                <form class="layui-form">
                    <input type="hidden" name="id" value="{$article.id}">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>资料传完时间</th>
                        </tr>
                        </thead>
                        <tr>
                            <td>
                                <div class="layui-inline">
                                    <input type="text" name="dataEndTime" id="dataEndTime" value="" autocomplete="off" class="layui-input" lay-verify="required">
                                </div>
                                <button class="layui-btn" lay-submit="" lay-filter="btn_setDataEndTime">保存</button>
                            </td>
                        </tr>
                    </table>
                </form>
                {/if}
            {else /}
            <table class="layui-table" lay-filter="test3">
                <thead>
                <tr>
                    <th lay-data="{field:'endTime'}">网站上线时间</th>
                    <th lay-data="{field:'endImg'}">网站上线确认书</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{$article.endTime}</td>
                    <td><a href="{$article.endImg}" target="_blank"><img src="{$article.endImg}" height="50"></a>  </td>
                </tr>
            </table>
            {/if}
        </div>
    </div>


    {if condition="$Think.session.admin.id==$article.kfID or $Think.session.admin.id==$article.editID or $Think.session.admin.id==$article.techID or $Think.session.admin.levelNum==50  "}
    <div class="layui-card">
        <div class="layui-card-header">添加跟进记录</div>
        <div class="layui-card-body">
            <form class="layui-form">
                <input type="hidden" name="webID" value="{$article.id}">
                <input type="hidden" name="typeID" value="0">
                <input type="hidden" name="userID" value="{$Think.session.admin.id}">
                <input type="hidden" name="name" value="客户跟进">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>联系人</th>
                        <th>内容</th>
                        <th>时间</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tr>
                        <td>
                            <input type="text" name="lxr" value="" placeholder="联系客户" autocomplete="off" class="layui-input" lay-verify="required">
                        </td>
                        <td>
                            <input type="text" name="content" value="" placeholder="联系内容" autocomplete="off" class="layui-input" lay-verify="required">
                        </td>
                        <td>
                            <div class="layui-inline">
                                <input type="text" name="inTime" id="inTime" value="" autocomplete="off" class="layui-input" lay-verify="required">
                            </div>
                        </td>
                        <td>
                            <button class="layui-btn" lay-submit="" lay-filter="btn_saveRecords">保存</button>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    {/if}

    <div class="layui-card">
        <div class="layui-card-header">网站进度</div>
        <div class="layui-card-body">
            <div class="layui-progress layui-progress-big" lay-showpercent="true" lay-filter="component-progress-demo">
                <div class="layui-progress-bar" lay-percent="{$article.progress}%" style="width:{$article.progress}%;"><span class="layui-progress-text">{$article.progress}%</span></div>
            </div>
            <table class="layui-table" lay-filter="progress" lay-data="{page:true, id:'progress'}" lay-size="sm">
                <thead>
                <tr>
                    <th lay-data="{field:'recordName'}">姓名</th>
                    <th lay-data="{field:'name'}">内容</th>
                    <th lay-data="{field:'inTime'}">时间</th>
                </tr>
                </thead>
                <tbody>
                    {volist name="progress_list" id="vo"}
                    <tr>
                        <td>{$vo.recordName}</td>
                        <td>{$vo.name}</td>
                        <td>{$vo.inTime}</td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-card-header">跟进详情</div>
        <div class="layui-card-body">
            <table class="layui-table" lay-filter="records" lay-data="{page:true, id:'records'}" lay-size="sm" >
                <thead>
                <tr>
                    <th lay-data="{field:'recordName'}">姓名</th>
                    <th lay-data="{field:'lxr'}">跟进对象</th>
                    <th lay-data="{field:'name'}">内容</th>
                    <th lay-data="{field:'inTime'}">时间</th>
                </tr>
                </thead>
                <tbody>
                    {volist name="$records" id="vo"}
                    <tr>
                        <td>{$vo.recordName}</td>
                        <td>{$vo.lxr}</td>
                        <td>{$vo.content}</td>
                        <td>{$vo.inTime}</td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>

    layui.config({
        base: '__STATIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: '/lib/index' //主入口模块
    }).use(['index', 'table','form','laydate'], function () {
        var $ = layui.$, form = layui.form, layer = layui.layer, table = layui.table, laydate = layui.laydate;

        laydate.render({elem: '#techEndTime', type: 'datetime', value: new Date(),});
        laydate.render({elem: '#dataEndTime', type: 'datetime', value: new Date(),});
        laydate.render({elem: '#inTime', type: 'datetime', value: new Date(),});
        laydate.render({elem: '#templateTime', type: 'datetime', value: new Date(),});
        table.init('test1');
        table.init('test2');
        table.init('test3');
        table.init('progress',{limit: 5});
        table.init('records',{limit: 10});



        //5编辑资料完成时间
        form.on('submit(btn_setDataEndTime)', function (data) {
            layer.open({
                content: '确认完成?'
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    $.post("{:url('setDataEndTime')}",data.field, function (result) {
                        if (result['code'] == 0) {
                            layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                location.reload();
                                // $.post("{:url('sendMail')}",{to:result['email'],name:'“浙江四为网络” - 网站提醒',body:'有网站资料传完啦~ 快去看看吧!'}, function (result) {
                                //     if (result['code'] == 0) {
                                //         layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                //             location.reload();
                                //         });
                                //     } else {
                                //         layer.msg(result['msg'], {icon: 3, time: 3000},function () {
                                //             location.reload();
                                //         });
                                //     }
                                // });
                            });
                        } else {
                            layer.msg(result['msg'], {icon: 3, time: 3000});
                        }
                    });
                    form.render();
                    layer.close(index);
                }
                ,btn2: function(index, layero){
                    layer.close(index);
                }
            });

            return false;
        });

        //4编辑跟进
        form.on('submit(btn_saveRecords)', function (data) {
            layer.open({
                content: '确认完成?'
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    $.post("{:url('saveRecords')}",data.field, function (result) {
                        if (result['code'] == 0) {
                            layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                location.reload();
                            });
                        } else {
                            layer.msg(result['msg'], {icon: 3, time: 3000});
                        }
                    });
                    form.render();
                    layer.close(index);
                }
                ,btn2: function(index, layero){
                    layer.close(index);
                }
            });

            return false;
        });



        //2技术完成框架，并邮件编辑
        form.on('submit(btn_setTechEndTime)', function (data) {
            layer.open({
                content: '确认完成?'
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    var websiteName=data.field.websiteName;
                    $.post("{:url('setTech')}",data.field, function (result) {
                        if (result['code'] == 0) {
                            layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                $.post("{:url('sendMail')}",{to:result['email'],name:'“'+websiteName+'” - 框架完成',body:websiteName+'技术已经完成框架了~ 快去加资料吧!'}, function (result) {
                                    if (result['code'] == 0) {
                                        layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                            location.reload();
                                        });
                                    } else {
                                        // layer.msg(result['msg'], {icon: 3, time: 3000});
                                        layer.msg(result['msg'], {icon: 3, time: 3000},function () {
                                            location.reload();
                                        });
                                    }
                                });
                            });
                        } else {
                            layer.msg(result['msg'], {icon: 3, time: 3000});
                        }
                    });
                    form.render();
                    layer.close(index);
                }
                ,btn2: function(index, layero){
                    layer.close(index);
                }
            });

            return false;
        });

        //编辑确认模版 ，发邮件给技术
        form.on('submit(btn_setTemplate)', function (data) {
            layer.open({
                content: '确认完成?'
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    var websiteName=data.field.websiteName;
                    $.post("{:url('setTemplate')}",data.field, function (result) {
                        if (result['code'] == 0) {
                            layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                $.post("{:url('sendMail')}",{to:result['email'],name:'“'+websiteName+'” - 网站模版确定',body:websiteName+'编辑确认模版啦~ 快去做网站吧!'}, function (result) {
                                    if (result['code'] == 0) {
                                        layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                            location.reload();
                                        });
                                    } else {
                                        // layer.msg(result['msg'], {icon: 3, time: 3000});
                                        layer.msg(result['msg'], {icon: 3, time: 3000},function () {
                                            location.reload();
                                        });
                                    }
                                });
                            });
                        } else {
                            layer.msg(result['msg'], {icon: 3, time: 3000});
                        }
                    });
                    form.render();
                    layer.close(index);
                }
                ,btn2: function(index, layero){
                    layer.close(index);
                }
            });

            return false;
        });


    });

</script>
{/block}